package com.dm_solution.powerlineswitch;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.TextureView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity2 extends BaseActivity {

	private void addButton()
	{
		Button button1 = (Button) findViewById(R.id.button1);
		button1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(),MainActivity.class));
				overridePendingTransition(R.anim.slide_left_in, R.anim.slide_left_out);
				Log.i("DaySevenActivity", "This is an info message");
		        Toast.makeText(getApplicationContext(), "This is a toast!", Toast.LENGTH_LONG).show();

		        Toast myToast = Toast.makeText(getApplicationContext(), R.string.app_name, Toast.LENGTH_SHORT);

		        myToast.setGravity(Gravity.CENTER, 0, 0);                                

		        LayoutInflater inflater = getLayoutInflater();

		        View toastLayout = inflater.inflate(R.layout.taost_layout, 

		                (ViewGroup) findViewById(R.id.newToastLayout));

		        TextView toastTextView = (TextView) toastLayout.findViewById(R.id.textView1);

		        toastTextView.setText("This is also a toast!");

		        myToast.setView(toastLayout);

		        myToast.show();    
			}
		});
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main2);
		addButton();
		


		Intent myIntent = getIntent();

		TextView textView1 = (TextView) findViewById(R.id.textView1);
		textView1.setText(myIntent.getStringExtra("MyString"));
		MyApplication myApp = (MyApplication) getApplication();
		//textView1.setText(myApp.getMyApplicationString());
	}


}
